package com.jml;

import java.util.Objects;


@FunctionalInterface
public interface Predicate<T> {
	
	
	boolean test(T t);
	
	
	
	
	default Predicate<T> negate() {
		return (t) -> !test(t);
	}
	
	
	default Predicate<T> or(Predicate<? super T> other) {
		Objects.requireNonNull(other);
		return (t) -> test(t) || other.test(t);
	}
	
 
	static <T> Predicate<T> isEqual(Object targetRef) {
		Predicate<T> tPredicate = object -> targetRef.equals(object);
		
		return (null == targetRef)
				? Objects::isNull
				: object -> targetRef.equals(object);
	}
}
